﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="Js/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function replaceAll(text, busca) {
            busca = busca.replace("'", '');
            while (text.toString().indexOf(busca) != -1)
                text = text.toString().replace(busca, '±');
            return text;
        }

       
        function testJson() {
        try{
            $.ajax({
                type: "POST",
                url: "http://10.11.9.153:87/Persona_SL.asmx/TestListPersons",
                data: "{sNumero_Documento:'" + $("#txtNumero").val() + "',sHuella:'" + replaceAll($("#flRuta").val(), '\'\\') + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    try {
                        $("#jsonResponse").html(msg);
                        var data = eval("(" + msg.d + ")");
                        var t = "<table width='100%' border='1px'> <tr>" +
                                "<td> <strong>persona_id</strong></td> " +
                                "<td> <strong>nombre</strong></td> " +
                                "<td> <strong>apellido paterno</strong></td>" +
                                "<td> <strong>apellido materno</strong></td> " +
                                "<td> <strong>numero documento</strong></td> " +
                                "<td> <strong>direccion id</strong></td> " +
                                "<td> <strong>descripcion</strong></td> " +
                                "<td> <strong>estado</strong></td> " +
                                "<td> <strong>tipo documento_id</strong></td> " +
                                "<td> <strong>descripcion</strong></td> " +
                                "<td> <strong>estado</strong></td> " +
                                "<td> <strong>genero</strong></td> " +
                                "<td> <strong>edad</strong></td> " +
                                "<td> <strong>foto</strong></td> " +
                                "<td> <strong>huella</strong></td> " +
                                "<td> <strong>estado</strong></td> </tr> ";
                        jQuery.each(data, function(rec) {
                            t = t + " <tr> <td> " + this.Int_persona_id + "</td> <td> " +
                                    this.Str_nombre + "</td> <td> " +
                                    this.Str_apellido_paterno + "</td> <td> " +
                                    this.Str_apellido_materno + "</td> <td> " +
                                    this.Str_numero_documento + "</td> <td> " +
                                    this.Direccion.Int_direccion_id + "</td> <td> " +
                                    this.Direccion.Str_descripcion + "</td> <td> " +
                                    this.Direccion.Chr_estado + "</td> <td> " +
                                    this.Documento.Int_tipo_documento_id + "</td> <td> " +
                                    this.Documento.Str_descripcion + "</td> <td> " +
                                    this.Documento.Chr_estado + "</td> <td> " +
                                    this.Chr_genero + "</td> <td> " +
                                    this.Int_edad + "</td> <td> " +
                                    "<img title='Foto' src='" + this.Txt_foto + "' /></td> <td> " +
                                    "<img title='Huella' src='" + this.Txt_huella + "' /></td> <td> " +
                                    this.Chr_estado + "</td> </tr> ";
                        });
                        t = t + " </table> ";
                        $("#jsonDiv").html(t);
                    } catch (ex) {
                        alert('error: ' + ex.description)
                    }

                },
                error: function(msg) {

                }

            });
            } catch (ex) {
                alert('error ajax: ' + ex.description)
            }
        };
    </script>

</head>
<body style ="font-family:Arial Narrow">
    <p>
        <table width ="100%">
            <tr>
                <td>
                    Ingrese Dni:
                </td>
                <td>
                    <input id="txtNumero" type="text" value="" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input id="flRuta" type="file" size="100%" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input id="testjson" type="button" value="Buscar" onclick="javascript:testJson();" />
                </td>
            </tr>
        </table>
        
    </p>
    <br />
    <div id="jsonResponse" style="display:block;"></div>
    <br />
    <div id="jsonDiv" style="display:block;"></div>
</body>
</html>
